package com.fh.shop.api.token.biz;

import com.fh.shop.api.common.Constant;
import com.fh.shop.util.ServerResponse;
import com.fh.shop.api.util.KeyUtil;
import com.fh.shop.util.RedisUtil;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service("tokenService")
public class ITokenServiceImpl implements ITokenService {
    @Override
    public ServerResponse tokenKey() {
        //生成随机的uuid
        UUID uuid = UUID.randomUUID();
        String key = KeyUtil.tokenKey(uuid.toString());
        //存入缓存中一份
        RedisUtil.setex(key,"", Constant.TOKEN_UUID);
        //响应给前台
        return ServerResponse.success(key);
    }
}
